<?php

require_once 'Naneau/Validator/Abstract.php';

require_once 'Zend/Validate/StringLength.php';
require_once 'Zend/Validate/Regex.php';
require_once 'Zend/Validate/Alnum.php';
require_once 'Zend/Validate/Digits.php';

class Naneau_Validator_Demo extends Naneau_Validator_Abstract {

    public function __construct() {
        $this->setRequired('name', 'Name is a required field');
        $this->addFieldValidator('name', new Zend_Validate_StringLength(1,150), 'Name must be between 1 and 5 characters long, yes, 5!');
        //name

        $this->addFieldValidator('numeric', new Zend_Validate_Digits(), 'Numeric must be... numeric.');
        //alnum

        $this->setRequired('alnum', 'Alnum is a required field');
        $this->addFieldValidator('alnum', new Zend_Validate_Alnum(), 'Alnum must be alpha-numeric, d\'oh!');
        //alnum

        $this->setRequired('url', 'Url is a required field');
        $this->addFieldValidator('url', new Zend_Validate_Regex('/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\//i'), 'Url has to be valid, try adding a trailing "/"');
        //url
    }
}